<?php
if (!defined('ipos')) die("Please contact Y!m: ichphien_pro or Email: ichphien_pro@yahoo.com.");
// danh sách phim
function ipos_acp_film($id = 0, $add = false) {
	global $db;
	$film = $db->database("phimid,tenphim","film","phimid!=0 ORDER BY tenphim ASC");
	$html = "<select name=\"film\">";
	if ($add) $html .= "<option onclick=\"$('#addfilm_new').slideDown();\" value=dont_edit".(($id == 0)?" selected":'').">Thêm phim mới</option>";
	for($i=0;$i<count($film);$i++) {
		$html .= "<option onclick=\"$('#addfilm_new').slideUp();\" value=".$film[$i][0].(($id == $film[$i][0])?" selected":'').">".$film[$i][1]."</option>";
	}
	$html .= "</select>";
	return $html;
}
// thể loại
function ipos_category($list_category=0) {
	global $db;
	$category 		= $db->database("danhmucid,danhmucten","category","danhmucid!=0 ORDER BY danhmucstt ASC");
	
	$list_category 	= explode(',',$list_category);
	for($i=0;$i<count($category);$i++) {
		if (in_array($category[$i][0],$list_category)) {
			$checked[$i]	=	"checked=\"checked\"";
		}
		$html .= "<div class=\"category\"><input style=\"width: 10px; cursor: pointer;\" type=\"checkbox\" name=\"theloai[]\" value=\"".$category[$i][0]."\" ".$checked[$i]."/> ".$category[$i][1]."</div>";
	}
	return $html;
}
// quốc gia
function ipod_country($id=0) {
	global	$db;
	$country 		= $db->database("quocgiaid,quocgiaten","country","quocgiaid!=0 ORDER BY quocgiastt ASC");
	$html .= "<select name=quocgia>";
	for($i=0;$i<count($country);$i++) {
		$quocgia_id	=	$country[$i][0];
		$html	.=	"<option value=$quocgia_id".(($id==$quocgia_id)?' selected':'').">".$country[$i][1]."</option>";
	}
	$html .= "</select>";
	return $html;
}

// phân loại phim
function ipod_film_pl($id=0) {
	$html = "<select name=phimbo>".
			"<option value=0".(($id==0)?' selected':'').">Phim Lẻ</option>".
			"<option value=1".(($id==1)?' selected':'').">Phim Bộ Đã Hoàn Thành</option>".
			"<option value=2".(($id==2)?' selected':'').">Phim Bộ Chưa Hoàn Thành</option>".
			"</select>";
	return $html;
}

function ipos_set_type($sv=0) {
    $html .= "<select name=\"server\">";
    $html .= "<option value=0".(($sv==0)?' selected':'').">None</option>";
    for ($i=1; $i<=m_get_config('total_server_media'); $i++) {
    $html.= "<option value=".$i."".(($sv==$i)?' selected':'').">Server ".$i." (".m_get_config('server_url_'.$i)."/".m_get_config('server_folder_'.$i)."/)</option>";
    }
    $html .= "</select>";
    return $html;
}


function ipos_advphanloai($name='') {
	$html = "<select name=adv_phanloai>".
			"<option value=0".(($id==0)?' selected':'').">Ảnh</option>".
			"<option value=1".(($id==1)?' selected':'').">Flash</option>".
			"<option value=2".(($id==2)?' selected':'').">HTML</option>".
			"</select>";
	return $html;
}
function ipos_status($name='',$id=0) {
	$html = "<select name=$name>".
			"<option value=0".(($id==0)?' selected':'').">Hiện</option>".
			"<option value=1".(($id==1)?' selected':'').">Ẩn</option>".
			"</select>";
	return $html;
}


function ipos_adv_list($name='') {
	$html = "<select name=adv_vitri>".
			"<option value=popup".(($name=='popup')?' selected':'').">popup</option>".
			"<option value=home_banner_1_left".(($name=='home_banner_1_left')?' selected':'').">(Home) banner 1 - left (475px x 80px)</option>".
			"<option value=home_banner_1_right".(($name=='home_banner_1_right')?' selected':'').">(Home) banner 1 - right (475px x 80px)</option>".
			"<option value=home_banner_2_left".(($name=='home_banner_2_left')?' selected':'').">(Home) banner 2 - left (475px x 80px)</option>".
			"<option value=home_banner_2_right".(($name=='home_banner_2_right')?' selected':'').">(Home) banner 2 - right (475px x 80px)</option>".
			"<option value=home_banner_3_left".(($name=='home_banner_3_left')?' selected':'').">(Home) banner 3 - left (475px x 80px)</option>".
			"<option value=home_banner_3_right".(($name=='home_banner_3_right')?' selected':'').">(Home) banner 3 - right (475px x 80px)</option>".
			"<option value=home_banner_4_left".(($name=='home_banner_4_left')?' selected':'').">(Home) banner 4 - left (475px x 80px)</option>".
			"<option value=home_banner_4_right".(($name=='home_banner_4_right')?' selected':'').">(Home) banner 4 - right (475px x 80px)</option>".
			"</select>";
	return $html;
}
function xem_web($url) {
  $ch = curl_init();
  $timeout = 5;
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
  curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $data = curl_exec($ch);
  curl_close($ch);
  return $data;
}
function grab($url) {
if (preg_match("#http://phim.clip.vn/watch/(.*?)/(.*?)#s",$url,$id_sr)){
    	$id 	= 	$id_sr[1];
		$id = explode(',', $id);
		$url	=	'http://clip.vn/embed/'.$id[1];		
	}
return $url;
}
?>